<!-- SQL Database partial -->
<script id="services.sqldatabase.subscriptions.id.servers.partial" type="text/x-handlebars-template">
    <div id="resource-name" class="list-group-item active">
        <h4 class="list-group-item-heading">{{name}}</h4>
    </div>

    <div class="list-group-item">
        <h4 class="list-group-item-heading">Information</h4>
        <div class="list-group-item-text item-margin">SQL Server Name: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.name">{{name}}</span></div>
        <div class="list-group-item-text item-margin">Azure Active Directory Admin: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.ad_admin"><samp>{{value_or_none ad_admin.login}}</samp></span></div>
        <div class="list-group-item-text item-margin">Auditing: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_auditing_disabled">{{ convert_bool_to_enabled auditing.auditing_enabled }}</span></div>
        <div class="list-group-item-text item-margin">Auditing retention period: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_low_auditing_retention">{{ auditing.retention_days }}</span></div>

        <div class="list-group-item-text item-margin">Advanced Threat Protection (ATP): <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_threat_detection_disabled">{{ convert_bool_to_enabled threat_detection.threat_detection_enabled }}</span></div>
        <div class="list-group-item-text item-margin">Advanced Threat Protection (ATP) alerts: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_threat_detection_alerts_disabled">{{ convert_bool_to_enabled threat_detection.alerts_enabled }}</span></div>
        <div class="list-group-item-text item-margin">Send Advanced Threat Protection (ATP) alerts: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_send_threat_detection_alerts_disabled">{{ convert_bool_to_enabled threat_detection.send_alerts_enabled }}</span></div>
        <div class="list-group-item-text item-margin">Advanced Threat Protection (ATP) retention period: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_low_threat_detection_retention">{{ threat_detection.retention_days }}</span></div>

        <div class="list-group-item-text item-margin">Storage account name: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_vulnerability_storage_account_name">{{server_vulnerability.storage_account_name }}</span></div>
        <div class="list-group-item-text item-margin">Send email notification to admins and subscription owners: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_vulnerability_email_subscription_admin">{{convert_bool_to_enabled server_vulnerability.email_subscription_admin }}</span></div>
        <div class="list-group-item-text item-margin">Periodic recurring scans: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_vulnerability_recurring_scans_enabled">{{convert_bool_to_enabled server_vulnerability.recurring_scans_enabled }}</span></div>
        <div class="list-group-item-text item-margin">Send scan report to is configured: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_vulnerability_send_scan_reports_to_not_empty">{{server_vulnerability.send_scan_reports_to_not_empty}}</span></div>

        <div class="list-group-item-text item-margin">TDE server key type: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.server_encryption_protectors_TDE_protector_is_encrypted">{{ encryption_protectors.server_key_type }}</span></div>

        <div class="list-group-item-text item-margin">Tags:
            {{#each tags}}
            <div
                style="border-radius: 5px; -webkit-border-radius: 5px; float: center; background-color: #c2c2d6; padding: 0.1px; text-align: center; display: inline-flex;">
                <samp>{{value_or_none this}}</samp>
            </div>&nbsp;&nbsp;
            {{else}}
            <div style="display: inline-flex;"><samp>None</samp></div>
            {{/each}}
        </div>
        <div class="list-group-item-text item-margin">Resource group: <span id="sqldatabase.subscriptions.{{@../key}}.servers.{{@key}}.resource_group_name"><samp>{{value_or_none resource_group_name}}</samp></span></div>
    </div>
    <div class="list-group-item">
        <h4 class="list-group-item-heading">SQL Databases</h4>
        <div class="list-group-item-text item-margin">
            {{#each databases}}
            <div class="list-group-item-text item-margin"><b>Database name: </b>{{@key}}</div>
            <div class="list-group-item-text item-margin">
                <div class="list-group-item-text item-margin">Auditing: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.databases.{{@key}}.db_auditing_disabled">{{ convert_bool_to_enabled auditing.auditing_enabled }}</span></div>
                <div class="list-group-item-text item-margin">Auditing retention period: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.databases.{{@key}}.db_low_auditing_retention">{{ auditing.retention_days }}</span></div>
                <div class="list-group-item-text item-margin">Threat detection: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.databases.{{@key}}.db_threat_detection_disabled">{{ convert_bool_to_enabled threat_detection.threat_detection_enabled }}</span></div>
                <div class="list-group-item-text item-margin">Threat detection alerts: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.databases.{{@key}}.db_threat_detection_alerts_disabled">{{ convert_bool_to_enabled threat_detection.alerts_enabled }}</span></div>
                <div class="list-group-item-text item-margin">Send threat detection alerts: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.databases.{{@key}}.db_send_threat_detection_alerts_disabled">{{ convert_bool_to_enabled threat_detection.send_alerts_enabled }}</span></div>
                <div class="list-group-item-text item-margin">Threat detection retention period: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.databases.{{@key}}.db_low_threat_detection_retention">{{ threat_detection.retention_days }}</span></div>
                <div class="list-group-item-text item-margin">Transparent data encryption: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.databases.{{@key}}.transparent_data_encryption_enabled">{{ convert_bool_to_enabled transparent_data_encryption_enabled }}</span></div>
                <div class="list-group-item-text item-margin">Geo-replication configured: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.databases.{{@key}}.replication_configured"><samp>{{ replication_configured }}</samp></span></div>
                <div class="list-group-item-text item-margin">Tags:
                    {{#each tags}}
                    <div
                            style="border-radius: 5px; -webkit-border-radius: 5px; float: center; background-color: #c2c2d6; padding: 0.1px; text-align: center; display: inline-flex;">
                        <samp>{{value_or_none this}}</samp>
                    </div>&nbsp;&nbsp;
                    {{else}}
                    <div style="display: inline-flex;"><samp>None</samp></div>
                    {{/each}}
                </div>
                <div class="list-group-item-text item-margin">Resource group: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.databases.{{@key}}.resource_group_name"><samp>{{value_or_none resource_group_name}}</samp></span></div>
            </div>
            {{/each}}
        </div>
    </div>

    <div class="list-group-item">
        <h4 class="list-group-item-heading">Firewall Rules</h4>
        <div class="list-group-item-text item-margin">
            {{#each firewall_rules}}
            <samp>{{name}}</samp>
            <div class="list-group-item-text item-margin">
                <div class="list-group-item-text item-margin">Firewall rule start IP: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.firewall_rules.{{@key}}.start_ip">{{start_ip}}</span></div>
                <div class="list-group-item-text item-margin">Firewall rule end IP: <span id="sqldatabase.subscriptions.{{@../../key}}.servers.{{@../key}}.firewall_rules.{{@key}}.end_ip">{{end_ip}}</span></div>
            </div>
            {{/each}}
        </div>
    </div>
</script>

<script>
    Handlebars.registerPartial("services.sqldatabase.subscriptions.id.servers", $("#services\\.sqldatabase\\.subscriptions\\.id\\.servers\\.partial").html());
</script>

<!-- Single SQL Database template -->
<script id="single_sqldatabase_servers-template" type="text/x-handlebars-template">
    {{> modal-template template='services.sqldatabase.servers' }}
</script>
<script>
    var single_sqldatabase_servers_template = Handlebars.compile($("#single_sqldatabase_servers-template").html());
</script>